#!/usr/bin/env python
#coding: utf-8
'''
Created on 2017年2月17日

@author: Administrator
'''
from django.conf import settings

DOMAIN_NAME = settings.DOMAIN_NAME
DEBUG = settings.DEBUG
ERROR = settings.ERROR
GRUNT_ON = settings.GRUNT_ON
MEDIA_URL = settings.MEDIA_URL
LOGIN_URL = settings.LOGIN_URL
LOGIN_SUCESS_URL = settings.LOGIN_SUCESS_URL
STATIC_GRUNT_ROOT = settings.STATIC_GRUNT_ROOT
AUTHENTICATION_BACKENDS = settings.AUTHENTICATION_BACKENDS
SESSION_COOKIE_DOMAIN = settings.SESSION_COOKIE_DOMAIN
#ELASTICSEARCH
ELASTICSEARCH_HOST = settings.ELASTICSEARCH_HOST

EMPTY_IMG_FPATH = ""
USERINFO_COOKIE_NAME = "userinfo"
CRYPTO_KEY = 'f056380ed970b169'
CRYPTO_IV = '912467427a354o9x'
OPEN_KEY = "52a5dad279cd11e4b5ea0016maxinlin"

class StateEnum:
    VALID = 0
    TEMPORARY = 1
    DELETED = 9
    
STATE_CHOICES = (
    (StateEnum.VALID, u'有效'),
    (StateEnum.TEMPORARY, u'临时记录'),
    (StateEnum.DELETED, u'删除'),
)

class BoolNumberEnum:
    NO = 0
    YES = 1
BOOL_NUMBER_CHOICES = (
    (BoolNumberEnum.NO, u'否'),
    (BoolNumberEnum.YES, u'是'),
)

def get_state_desc(state):
    for st in STATE_CHOICES:
        if st[0] == state:
            return st[1]
    return u"正常"

USER_AGENTS = [
    "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; AcooBrowser; .NET CLR 1.1.4322; .NET CLR 2.0.50727)",
    "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; Acoo Browser; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.0.04506)",
    "Mozilla/4.0 (compatible; MSIE 7.0; AOL 9.5; AOLBuild 4337.35; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)",
    "Mozilla/5.0 (Windows; U; MSIE 9.0; Windows NT 9.0; en-US)",
    "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET CLR 2.0.50727; Media Center PC 6.0)",
    "Mozilla/5.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET CLR 1.0.3705; .NET CLR 1.1.4322)",
    "Mozilla/4.0 (compatible; MSIE 7.0b; Windows NT 5.2; .NET CLR 1.1.4322; .NET CLR 2.0.50727; InfoPath.2; .NET CLR 3.0.04506.30)",
    "Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN) AppleWebKit/523.15 (KHTML, like Gecko, Safari/419.3) Arora/0.3 (Change: 287 c9dfb30)",
    "Mozilla/5.0 (X11; U; Linux; en-US) AppleWebKit/527+ (KHTML, like Gecko, Safari/419.3) Arora/0.6",
    "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.2pre) Gecko/20070215 K-Ninja/2.1.1",
    "Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9) Gecko/20080705 Firefox/3.0 Kapiko/3.0",
    "Mozilla/5.0 (X11; Linux i686; U;) Gecko/20070322 Kazehakase/0.4.5",
    "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.8) Gecko Fedora/1.9.0.8-1.fc10 Kazehakase/0.5.6",
    "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11",
    "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/535.20 (KHTML, like Gecko) Chrome/19.0.1036.7 Safari/535.20",
    "Opera/9.80 (Macintosh; Intel Mac OS X 10.6.8; U; fr) Presto/2.9.168 Version/11.52",
    "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.11 (KHTML, like Gecko) Chrome/20.0.1132.11 TaoBrowser/2.0 Safari/536.11",
    "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.71 Safari/537.1 LBBROWSER",
    "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E; LBBROWSER)",
    "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; QQDownload 732; .NET4.0C; .NET4.0E; LBBROWSER)",
    "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.84 Safari/535.11 LBBROWSER",
    "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E)",
    "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E; QQBrowser/7.0.3698.400)",
    "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; QQDownload 732; .NET4.0C; .NET4.0E)",
    "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; SV1; QQDownload 732; .NET4.0C; .NET4.0E; 360SE)",
    "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; QQDownload 732; .NET4.0C; .NET4.0E)",
    "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E)",
    "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.89 Safari/537.1",
    "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.89 Safari/537.1",
    "Mozilla/5.0 (iPad; U; CPU OS 4_2_1 like Mac OS X; zh-cn) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8C148 Safari/6533.18.5",
    "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:2.0b13pre) Gecko/20110307 Firefox/4.0b13pre",
    "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:16.0) Gecko/20100101 Firefox/16.0",
    "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.64 Safari/537.11",
    "Mozilla/5.0 (X11; U; Linux x86_64; zh-CN; rv:1.9.2.10) Gecko/20100922 Ubuntu/10.10 (maverick) Firefox/3.6.10"
]
#
#PROXIES = [
#    {'ip_port': '61.172.249.96:80', 'user_pass': ''},
#    {'ip_port': '59.76.81.3:8080', 'user_pass': ''},
#    {'ip_port': '202.98.11.101:8080', 'user_pass': ''},
#    {'ip_port': '220.194.55.160:3128', 'user_pass': ''},
#    {'ip_port': '125.70.229.30:8080', 'user_pass': ''},
#    {'ip_port': '220.194.55.244:3128', 'user_pass': ''},
#    {'ip_port': '125.39.129.67:80', 'user_pass': ''},
#    {'ip_port': '221.204.246.116:3128', 'user_pass': ''},
#    {'ip_port': '218.75.75.133:8080', 'user_pass': ''},
#    {'ip_port': '61.53.137.50:8080', 'user_pass': ''},
#    {'ip_port': '222.68.207.11:80', 'user_pass': ''},
#    {'ip_port': '218.26.219.186:8080', 'user_pass': ''},
#    {'ip_port': '221.8.9.6:80', 'user_pass': ''},
#    {'ip_port': '60.12.227.208:80', 'user_pass': ''},
#    {'ip_port': '211.167.248.228:8080', 'user_pass': ''},
#    {'ip_port': '218.75.100.114:8080', 'user_pass': ''},
#    {'ip_port': '211.155.234.99:80', 'user_pass': ''},
#    {'ip_port': '60.28.196.27:80', 'user_pass': ''},
#    {'ip_port': '210.74.130.34:8080', 'user_pass': ''},
#    {'ip_port': '221.226.3.141:3128', 'user_pass': ''},
#    {'ip_port': '203.171.230.230:80', 'user_pass': ''},
#    {'ip_port': '221.130.202.206:80', 'user_pass': ''},
#    {'ip_port': '61.178.63.197:3128', 'user_pass': ''},
#    {'ip_port': '219.132.142.10:8080', 'user_pass': ''},
#    {'ip_port': '221.195.40.145:80', 'user_pass': ''},
#    {'ip_port': '121.9.221.188:80', 'user_pass': ''},
#    {'ip_port': '121.11.87.171:80', 'user_pass': ''},
#]


PROXIES = [
    {'ip_port': '111.11.228.75:80', 'user_pass': ''},
    {'ip_port': '120.198.243.22:80', 'user_pass': ''},
    {'ip_port': '111.8.60.9:8123', 'user_pass': ''},
    {'ip_port': '101.71.27.120:80', 'user_pass': ''},
    {'ip_port': '122.96.59.104:80', 'user_pass': ''},
    {'ip_port': '122.224.249.122:8088', 'user_pass': ''},
]
class RegexEnum:
    # 手机
    MOBILE = r'^1[34578]\d{9}$'
    # email
    EMAIL = r'^[a-zA-z0-9][\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$'
    # 合法的手机或email账号
    USERNAME = r'(^1[34578]\d{9}$)|(^[a-zA-z0-9][\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$)'
    # 密码
    PASSWORD = r'^[^\s]{6,16}$'
    # 用户类型
    USER_TYPE = r'^[012]$'
    # 32位UUID编号
    UUID_NO = r'^[0-9a-fA-F]{32}$'
    # 验证码
    VERIFYCODE = r'^[0-9a-zA-Z]{1,8}$'
    # 性别
    USER_SEX = r'^[NMF]$'
    # ID
    ID = r'^\d+$'
    # ID列表字符串，已都好分隔
    IDS = r'^(\d+,)*(\d+)$'
    # BOOL(0-False,1-True)
    BOOLEAN = r'^[01]$'
    # 整数或小数
    NUMBER = r'^(-?\d*)(\.\d+)?$'
    # state状态
    STATE = r'^[019]$'
